package xjay.ai.emotionalsupport.agent;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

@Data
@Component
public class AgentPromptConfig {

    private final String promptBasePath = "classpath:prompt/";
    private ResourcePatternResolver resolver;
    public AgentPromptConfig(ResourcePatternResolver resolver) {
        this.resolver = resolver;
    }

    public String loadAgentPrompt(String filename) throws IOException {
        String path = promptBasePath + filename;
        Resource resource = resolver.getResource(path);
        return resource.getContentAsString(StandardCharsets.UTF_8);
    }
}
